{extend name="base" /} {block name="body"}

<!--tab标签-->
<div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
                <li class="layui-this">编辑导航</li>
       </ul>
    
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" data-url="{:url('admin/navcms/update')}" localtion-url="{:url('navcms/index')}">
                <div class="layui-form-item">
                        <label class="layui-form-label">导航位置</label>
                        <div class="layui-input-inline" style="width:300px">
                            <input type="radio" name="pid" value="1" title="顶部" {if condition="$nav.pid==1" } checked="checked" {/if}>
                            <input type="radio" name="pid" value="0" title="底部" {if condition="$nav.pid==0" } checked="checked" {/if}>
                            <input type="radio" name="pid" value="2" title="首页中部" {if condition="$nav.pid==2" } checked="checked" {/if}>
                        </div>
                    </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上级分类</label>


                    <div class="layui-input-inline">
                        <select name="tid">

                       <div class='2'>
                        <option value="0">无</option>
                          {volist name="nav_level" id="vo"}
                        <option value="{$vo.id}" {if $nav.tid eq $vo.id} selected {/if}>{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq}{$vo.name}</option>
                          {/volist}
                        </div>

                          </select>
                    </div>
                </div>         
         
            {if $nav.sid eq 1}
                
                <div class="layui-form-item">
                        <label class="layui-form-label">系统栏目</label>
                        <div class="layui-input-inline">
                            <select name="link">
                              {volist name="category_level_list" id="vo"}
                              <option value="{$vo.id}" {if condition="$nav.link==$vo.id" } selected{/if}>{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq}{$vo.name}</option>
                               {/volist}
                              </select>
                        </div>
                </div>
            {else /}
            <div class="layui-form-item">
                <label class="layui-form-label">链接地址</label>
                <div class="layui-input-inline">
                    <input type="text"  name="link" value="{$nav.link}" required lay-verify="required" placeholder="请输入导航名称" class="layui-input">
                </div>
            </div>
            {/if}

                <div class="layui-form-item">
                    <label class="layui-form-label">导航名称</label>
                    <div class="layui-input-inline">
                        <input type="text" id="nav_name"  name="name" value="{$nav.name}" required lay-verify="required" placeholder="请输入导航名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">别名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="alias" value="{$nav.alias}" placeholder="（选填）请输入导航别名" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">图标</label>
                    <div class="layui-input-inline">
                        <input type="text" name="icon" value="{$nav.icon}" placeholder="（选填）如：fa fa-home" class="layui-input">
                    </div>
                </div>
               
                <div class="layui-form-item">
                    <label class="layui-form-label">打开方式</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="target" value="_self" title="默认" {if condition="$nav.target=='_self'" } checked="checked" {/if}>
                        <input type="radio" name="target" value="_blank" title="新窗口" {if condition="$nav.target=='_blank'" } checked="checked" {/if}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sort" value="{$nav.sort}" required lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="btable-paged">
                    <div class="layui-main">
                        <div class="formbtngroup">
                            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="formadd">更新</button>
                            <button onclick="history.go(-1);return false;" class="layui-btn layui-btn-primary layui-btn-sm">返回</button>
                        </div>
                    </div>
                </div> <input type="hidden" name="id" value="{$nav.id}">

            </form>
        </div>
    </div>
</div>

{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/formadd.js"></script>
<script>
    layui.use(['form', 'upload'], function() {
        var form = layui.form,
            upload = layui.upload,
            $ = layui.jquery;
        upload.render({
            elem: '#image',
            url: '{:url("upload/upimage")}',
            before: function(obj) {
                obj.preview(function(index, file, result) {
                    $('#picshow').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res) {
                if (res.code == '200') {
                    $('input[name=icon]').val(res.path);
                    return layer.msg('上传成功');
                } else {
                    return layer.msg(res.msg);
                }

            }
        });
        form.on('select(link)', function(data){
            $("#nav_name").val($(data.elem).find("option:selected").text().replace(/[|-\s]/g, ''));
        });  
    })
</script>
{/block}